{% extends "user/dashboard_base.html" %}

{% block subcontainer %}
<div class="pulls bubble">
  <div class="header">
    <h2 class="heading">我创建的</h2>
    <span class="sortable btn-group">
      <a href="#" {# if current == '/dashboard/pull/' %}class="active"{% endif #} id="pullMerge" class="btn btn-mini first">需要我处理的</a>
      <a href="#" {# if current == '/dashboard/pull/request/' %}class="active"{% endif #} id="pullRequest" class="btn btn-mini btn-disable last">我创建的</a>
    </span>
    {% comment %}
    <span class="sortable btn-group">
      <a href="#" class="btn btn-mini btn-disable first">进行中</a>
      <a href="#" class="btn btn-mini last">已处理</a>
    </span>
    {% endcomment %}
  </div>

  {% if pullRequests %}
  {% for pullRequest in pullRequests %}
  <section class="pull-item">
    <div class="widget">
      <span class="status {{pullRequest.status_label}}">{{pullRequest.status_view}}</span>
      <span class="branches">
        <a href="/{{pullRequest.source_repo.username}}/{{pullRequest.source_repo.name}}/tree/{{pullRequest.source_refname}}/" class="from branch" title="{{pullRequest.source_refname}}">{{pullRequest.source_refname|truncatechars:10}}</a>
        <span class="arrow-right"><i class="icon-long-arrow-right"></i></span>
        <a href="/{{pullRequest.desc_repo.username}}/{{pullRequest.desc_repo.name}}/tree/{{pullRequest.desc_refname}}/" class="to branch" title="{{pullRequest.desc_refname}}">{{pullRequest.desc_refname}}</a>
      </span>
    </div>
    <div class="summary">
      <h3 class="heading">
        <a href="/{{pullRequest.desc_repo.username}}/{{pullRequest.desc_repo.name}}/pull/{{pullRequest.id}}/">{{pullRequest.short_title}}</a>
        <a href="/{{pullRequest.desc_repo.username}}/{{pullRequest.desc_repo.name}}/pull/{{pullRequest.id}}/" class="id">#{{pullRequest.id}}</a>
      </h3>
      <div class="desc">
        <p>{{pullRequest.short_desc}}</p>
      </div>
      <div class="meta">
        <img src="https://gravatar.com/avatar/{{pullRequest.desc_repo.username}}?s=16" alt="{{pullRequest.desc_repo.username}}">
        <a href="#">{{pullRequest.desc_repo.username}}</a>
        <time class="unixtime" pubdate="pubdate">{{pullRequest.modify_time|date:"U"}}</time>
      </div>
    </div>
  </section>
  {% endfor %}


  {% else %}
  <div class="inner">
    <p class="alert blank-alert"><i class="icon-bell"></i><em>没有合并请求</em></p>
  </div>
  {% endif %}
</div>


{% endblock %}

{% block js %}
<script>
  $(function(){
    moment.lang('zh-cn');
    $('#pullMerge').click(function(){
      window.location.href = '/dashboard/pull/';
    });
    $('#pullRequest').click(function(){
      window.location.href = '/dashboard/pull/request/';
    });
  });
</script>
{% endblock %}
